class Solution {
    public int maxScoreSightseeingPair(int[] values) {
        int ret = 0;
        int mx = values[0];
        for (int i = 1; i < values.length; i++) {
            ret = Math.max(ret, mx + values[i] - i);
            mx = Math.max(mx, values[i] + i);
        }
        return ret;
    }
}